import { ofType, StateObservable } from 'redux-observable';
import { Observable, of } from 'rxjs';
import { switchMap, mapTo } from 'rxjs/operators';
import { ADD, SUB, sub } from './actions';
import {} from 'rxjs';
const addEpics = (action$: Observable<any>, state$: StateObservable<any>) => {
  return action$.pipe(
    ofType(ADD),
    switchMap((action: any) => {
      console.log(action);
      return of(sub());
    })
  );
};

const pingEpic = (action$: Observable<any>) =>
  action$.pipe(ofType('PING'), mapTo({ type: 'PONG' }));

export { addEpics, pingEpic };
